/*
 * CategoriesDetailForm_View.java
 * Dibuat untuk percontohan final project mata kuliah
 * Pemrograman Lanjut yang diampu oleh M. Fairul Filza, M.Kom
 * STMIK AMIKOM Yogyakarta Tempat Kuliah Orang Berdasi
 * Created on 21 Oct 2013, 08:45:19
 */

package Views;

// <editor-fold defaultstate="collapsed" desc="Import Code">
//import Controllers.CdSales_Controller;
import Controllers.Transaction_Controller;
import Interfaces.ViewsProcess_Interface;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.table.DefaultTableModel;
// </editor-fold>

/** @author FaiFilza@Amikom.ac.id */
public class Transaction_ListView extends JPanel implements ViewsProcess_Interface {
    // Class Attribute
    private ImageIcon Image;

    // <editor-fold defaultstate="collapsed" desc="Layout Attribute">
    // Initialize Component Panel
    
    private JLabel LblWallpaper;
//    private JButton BtnEdit;
    private JButton BtnDelete;
//    private JButton BtnRefresh;
    private JButton BtnFind;  
    private JLabel LblCode;
    private JScrollPane ScrTable;
    private JScrollPane ScrTable1;
    private JTable TblData;
    private JTable TblDetail;
    private JComboBox CboMonth;
    private JComboBox CboYear;
// </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructor Code">
    public Transaction_ListView() {
        LblWallpaper = new JLabel();
//        BtnEdit = new JButton();
        BtnDelete = new JButton();
//        BtnRefresh = new JButton();
        BtnFind  = new JButton();
        ScrTable = new JScrollPane();
        TblData = new JTable();
        ScrTable1 = new JScrollPane();
        TblDetail = new JTable();
        LblCode = new JLabel();
        CboMonth = new JComboBox();
        CboYear = new JComboBox();
        initComponents();
    }
    

    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Getter and Setter Code">
    
    public JLabel getLblWallpaper(){
        return LblWallpaper;
    }
    public void setLblWallpaper(JLabel LblWallpaper){
        this.LblWallpaper = LblWallpaper;
    }
//    public JButton getBtnEdit(){
//        return BtnEdit;
//    }
//    public void setBtnEdit(JButton BtnEdit){
//        this.BtnEdit = BtnEdit;
//    }
    public JButton getBtnDelete(){
        return BtnDelete;
    }
    public void setBtnDelete(JButton BtnDelete){
        this.BtnDelete = BtnDelete;
    }
//    public JButton getBtnRefresh(){
//        return BtnRefresh;
//    }
//    public void setBtnRefresh(JButton BtnRefresh){
//        this.BtnRefresh = BtnRefresh;
//    }
    public JButton getBtnFind(){
        return BtnFind;
    }
    public void setBtnReFind(JButton BtnFind){
        this.BtnFind = BtnFind;
    }

    public JScrollPane getScrTable() {
        return ScrTable;
    }

    public void setScrTable(JScrollPane ScrTable) {
        this.ScrTable = ScrTable;
    }

    public JScrollPane getScrTable1() {
        return ScrTable1;
    }

    public void setScrTable1(JScrollPane ScrTable1) {
        this.ScrTable1 = ScrTable1;
    }

    public JTable getTblData() {
        return TblData;
    }

    public void setTblData(JTable TblData) {
        this.TblData = TblData;
    }

    public JTable getTblDetail() {
        return TblDetail;
    }

    public void setTblDetail(JTable TblDetail) {
        this.TblDetail = TblDetail;
    }
    public JLabel getLblCode() {
        return LblCode;
    }

    public void setLblCode(JLabel LblCode) {
        this.LblCode = LblCode;
    }

    public JComboBox getCboMonth() {
        return CboMonth;
    }

    public void setCboMonth(JComboBox CboMonth) {
        this.CboMonth = CboMonth;
    }

    public JComboBox getCboYear() {
        return CboYear;
    }

    public void setCboYear(JComboBox CboYear) {
        this.CboYear = CboYear;
    }
    
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Method Code">
    private void createKeybindings(JTable table) {
        table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "Enter");
        table.getActionMap().put("Enter", new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                //do something on JTable enter pressed
            }
        });
    }
//    public JPanel pnlEntities() {
//        JPanel Panel = new JPanel();
//        Font FontStyle = new Font("Tahoma", 1, 12);
//
//        Panel.setLayout(null);
//        Panel.setBackground(new Color(0, 0, 0));
//        Panel.setOpaque(true);
//        
////        BtnEdit.setOpaque(false);
////        BtnEdit.setBorderPainted(false);
////        BtnEdit.setContentAreaFilled(false);
////        BtnEdit.setBorder(null);
////        BtnEdit.setVisible(true);
////        Panel.add(BtnEdit);
////        BtnEdit.setBounds(7,272,118,35);
//        
//        BtnDelete.setOpaque(false);
//        BtnDelete.setBorderPainted(false);
//        BtnDelete.setContentAreaFilled(false);
//        BtnDelete.setBorder(null);
//        BtnDelete.setVisible(true);
//        Panel.add(BtnDelete);
//        BtnDelete.setBounds(7,325,118,35);
//        
////        BtnRefresh.setOpaque(false);
////        BtnRefresh.setBorderPainted(false);
////        BtnRefresh.setContentAreaFilled(false);
////        BtnRefresh.setBorder(null);
////        BtnRefresh.setVisible(true);
////        Panel.add(BtnRefresh);
////        BtnRefresh.setBounds(7,220,118,35);
//        
//        BtnFind.setOpaque(false);
//        BtnFind.setBorderPainted(false);
//        BtnFind.setContentAreaFilled(false);
//        BtnFind.setBorder(null);
//        BtnFind.setVisible(true);
//        Panel.add(BtnFind);
//        BtnFind.setBounds(7,272,118,35);
//        LblCode.setVisible(false);
//        LblCode.setFont(FontStyle);
//        LblCode.setText(null);
//        Panel.add(LblCode);
//        LblCode.setBounds(35, 144, 20, 20);
//        TblData.setModel(new DefaultTableModel(
//            new Object [][] {
//
//            },
//            new String [] {
//
//            }
//        ));
//        ScrTable.setViewportView(TblData);
//        Panel.add(ScrTable);
//        ScrTable.setBounds(258, 407, 598, 140);
//
//        TblDetail.setModel(new DefaultTableModel(
//            new Object [][] {
//
//            },
//            new String [] {
//
//            }
//        ));
//        ScrTable1.setViewportView(TblDetail);
//        Panel.add(ScrTable1);
//        ScrTable1.setBounds(155, 224, 824, 147);
//
//
//        getLblWallpaper().setText(null);
//        getLblWallpaper().setBackground(new Color(250, 0, 250));
//        getLblWallpaper().setOpaque(false);
//        Panel.add(getLblWallpaper());
//        getLblWallpaper().setBounds(139, 163, 847, 402);
//
//        eventControllers();
//        imageControllers();
//        return Panel;
//    }

    @Override
    public void eventControllers() {
        
       Transaction_Controller ControlPanel = new Transaction_Controller(this);
            this.addComponentListener(ControlPanel.ListComponent_Listener);
//        BtnEdit.addActionListener(ControlPanel.ListButton_Listener);
//        BtnEdit.addMouseListener(ControlPanel.ListButtonImg_Listener);
//        BtnRefresh.addActionListener(ControlPanel.ListButton_Listener);
//        BtnRefresh.addMouseListener(ControlPanel.ListButtonImg_Listener);
            BtnFind.addActionListener(ControlPanel.ListButton_Listener);
        BtnDelete.addActionListener(ControlPanel.ListButton_Listener);
        BtnDelete.addMouseListener(ControlPanel.ListButtonImg_Listener);
        TblData.addKeyListener(ControlPanel.ViewKey_Listener);
        createKeybindings(TblData);
    }

    @Override
    public void imageControllers() {
        Image = new ImageIcon(getClass().getResource("/Images/sales2.png"));
        LblWallpaper.setIcon(Image);
//        Image = new ImageIcon(getClass().getResource("/Images/edit.png"));
//        BtnEdit.setIcon(Image);
        Image = new ImageIcon(getClass().getResource("/Images/delete3.png"));
        BtnDelete.setIcon(Image);
//        Image = new ImageIcon(getClass().getResource("/Images/refresh.png"));
//        BtnRefresh.setIcon(Image);
        Image = new ImageIcon(getClass().getResource("/Images/find.png"));
        BtnFind.setIcon(Image);
        
    }
    // </editor-fold>

    @Override
    public void initComponents() {
        
        Font FontStyle = new Font("Tahoma", 1, 12);

        setLayout(null);
        setBackground(new Color(0, 0, 0));
        setOpaque(true);
        
//        BtnEdit.setOpaque(false);
//        BtnEdit.setBorderPainted(false);
//        BtnEdit.setContentAreaFilled(false);
//        BtnEdit.setBorder(null);
//        BtnEdit.setVisible(true);
//        Panel.add(BtnEdit);
//        BtnEdit.setBounds(7,272,118,35);
        
        BtnDelete.setOpaque(false);
        BtnDelete.setBorderPainted(false);
        BtnDelete.setContentAreaFilled(false);
        BtnDelete.setBorder(null);
        BtnDelete.setEnabled(false);
        BtnDelete.setVisible(true);
        BtnDelete.setCursor(new Cursor(Cursor.HAND_CURSOR));
        add(BtnDelete);
        BtnDelete.setBounds(7,325,118,35);
        
//        BtnRefresh.setOpaque(false);
//        BtnRefresh.setBorderPainted(false);
//        BtnRefresh.setContentAreaFilled(false);
//        BtnRefresh.setBorder(null);
//        BtnRefresh.setVisible(true);
//        Panel.add(BtnRefresh);
//        BtnRefresh.setBounds(7,220,118,35);
        
                CboMonth.setOpaque(false);
        CboMonth.setBorder(null);
        CboMonth.setFont(FontStyle);
        CboMonth.setModel(new DefaultComboBoxModel(new String[] {}));
        add(CboMonth);
        CboMonth.setBounds(369 + 250, 77+90, 186, 22);

        CboYear.setOpaque(false);
        CboYear.setBorder(null);
        CboYear.setFont(FontStyle);
        CboYear.setModel(new DefaultComboBoxModel(new String[] {}));
        add(CboYear);
        CboYear.setBounds(623 + 185, 77+90, 93, 22);

        
        BtnFind.setOpaque(false);
        BtnFind.setBorderPainted(false);
        BtnFind.setContentAreaFilled(false);
        BtnFind.setBorder(null);
        BtnFind.setVisible(true);
        BtnFind.setCursor(new Cursor(Cursor.HAND_CURSOR));
        add(BtnFind);
        BtnFind.setBounds(885,160,118,35);
        LblCode.setVisible(false);
        LblCode.setFont(FontStyle);
        LblCode.setText(null);
        add(LblCode);
        LblCode.setBounds(35, 144, 20, 20);
        TblData.setModel(new DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        ScrTable.setViewportView(TblData);
//        ScrTable.setCursor(new Cursor(Cursor.HAND_CURSOR));
        add(ScrTable);
        ScrTable.setBounds(258, 412, 598, 140);

        TblDetail.setModel(new DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        ScrTable1.setViewportView(TblDetail);
        add(ScrTable1);
        ScrTable1.setBounds(155, 229, 824, 147);


        getLblWallpaper().setText(null);
        getLblWallpaper().setBackground(new Color(250, 0, 250));
        getLblWallpaper().setOpaque(false);
        add(getLblWallpaper());
        getLblWallpaper().setBounds(139, 163, 855, 413);

        eventControllers();
        imageControllers();
    }
}